<!--StartFragment-->
<style type="text/css">
.cf { font-family: Courier New; font-size: 10pt; color: black; background: white; padding-top: 0pt; padding-left: 0pt; padding-right: 0pt; padding-bottom: 0pt; }
.cl { margin: 0px; }
.cb1 { color: green; }
.cb2 { color: blue; }
</style>
<div class="cf">
<p class="cl"><span class="cb1">// We create nntp client object.</span></p>
<p class="cl">NntpClient nntp = <span class="cb2">new</span> NntpClient();</p>
<p class="cl">&nbsp;</p>
<p class="cl"><span class="cb2">try</span></p>
<p class="cl">{</p>
<p class="cl">&nbsp;&nbsp;&nbsp; <span class="cb1">// We connect to the nntp server.</span></p>
<p class="cl">&nbsp;&nbsp;&nbsp; nntp.Connect(_tbNntpServer.Text);</p>
<p class="cl">&nbsp;</p>
<p class="cl">&nbsp;&nbsp;&nbsp; <span class="cb1">// Get a news group on the server</span></p>
<p class="cl">&nbsp;&nbsp;&nbsp; <span class="cb1">// Gets article ids that belong to the "myhost.info" newsgroup and have been added less than one month ago.</span></p>
<p class="cl">&nbsp;&nbsp;&nbsp; <span class="cb2">string</span>[] newids = nntp.GetNewArticleIds(_tbNewsgroup.Text, System.DateTime.Now.AddMonths(-1));</p>
<p class="cl">&nbsp;</p>
<p class="cl">&nbsp;&nbsp;&nbsp; <span class="cb1">// We get each article as an object.</span></p>
<p class="cl">&nbsp;&nbsp;&nbsp; <span class="cb2">foreach</span> (<span class="cb2">string</span> articleId <span class="cb2">in</span> newids)</p>
<p class="cl">&nbsp;&nbsp;&nbsp; {</p>
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ActiveUp.Net.Mail.Message message = nntp.RetrieveArticleObject(articleId);</p>
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb1">//Display the subject.</span></p>
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb2">this</span>.AddLogEntry(<span class="cb2">string</span>.Format(<span class="cb2">"Subject : {0}"</span>,message.Subject));</p>
<p class="cl">&nbsp;&nbsp;&nbsp; } </p>
<p class="cl">}</p>
<p class="cl">&nbsp;</p>
<p class="cl"><span class="cb2">catch</span> (NntpException pexp)</p>
<p class="cl">{</p>
<p class="cl">&nbsp;&nbsp;&nbsp; <span class="cb2">this</span>.AddLogEntry(<span class="cb2">string</span>.Format(<span class="cb2">"Nntp Error: {0}"</span>, pexp.Message));</p>
<p class="cl">}</p>
<p class="cl">&nbsp;</p>
<p class="cl"><span class="cb2">catch</span> (Exception ex)</p>
<p class="cl">{</p>
<p class="cl">&nbsp;&nbsp;&nbsp; <span class="cb2">this</span>.AddLogEntry(<span class="cb2">string</span>.Format(<span class="cb2">"Failed: {0}"</span>, ex.Message));</p>
<p class="cl">}</p>
<p class="cl">&nbsp;</p>
<p class="cl"><span class="cb2">finally</span></p>
<p class="cl">{</p>
<p class="cl">&nbsp;&nbsp;&nbsp; <span class="cb2">if</span> (nntp.IsConnected)</p>
<p class="cl">&nbsp;&nbsp;&nbsp; {</p>
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; nntp.Disconnect(); ;</p>
<p class="cl">&nbsp;&nbsp;&nbsp; }</p>
<p class="cl">}</p>
</div>
<!--EndFragment-->
